<!-- 登录窗口 begin -->
<div class="login-box">
	<div class="login-form">
		<form method="post" action="<?php echo $this->url(array('controller' => 'user', 'action' => 'login'));?>" name="login">
			<label>用户名:</label>
			<input name="username" type="text" value="">
			<label>密码:</label>
			<input name="password" type="password" value="">
			<label>验证码:</label>
			<input name="captcha" class="captcha" type="text" value="">
			<input name="login" value="" type="submit">
			<div id="captcha-box">
				<img id="captcha-img" alt="验证码" src="<?php echo $this->url(array('controller' => 'utility', 'action' => 'captcha'));?>">
				<a id="refresh-captcha" target="_self" href="javascript:;">点击更换验证码</a>
			</div>
		</form>
	</div>
	
	<script type="text/javascript">
		$(document).ready(function() {
			function fixLoginBoxPos() {
				var browserHeight = $(window).height();
				var loginBoxHeight = $('.login-box').height();
				var topOffset = (browserHeight - loginBoxHeight) >= 0 ? (browserHeight - loginBoxHeight) / 2 : 0;
				$('.login-box').css({'margin-top':topOffset + 'px'});
			}

			fixLoginBoxPos();

			$(window).resize(function() {
				fixLoginBoxPos();
			});

			$('.login-form .captcha').focus(function() {
				$('#captcha-box').show();
			});

			$('.login-form .captcha').blur(function() {
				//$('#captcha-box').hide();
			});

			$('#refresh-captcha').click(function() {
				var random = Math.random();
				var url = '/utility/captcha?size=normal&random=' + random;
				$('#captcha-img').attr('src', url);
			})
		});
	</script>
</div>
<!-- 登录窗口 end -->